#include<iostream>
#include<unistd.h>
#include<signal.h>


void handler(int signo)
{
    std::cout<<"get a sig: "<<signo <<std::endl;
    sleep(100);
    exit(1);
}

int main()
{
    struct sigaction act,oact;
    act.sa_handler = handler;                //
    sigemptyset(&act.sa_mask);               //
    act.sa_flags = 0;
    sigaction(2,&act,&oact);

    while(true)
    {
        std::cout<<"I am a process, pid: "<<getpid()<<std::endl;

        sleep(1);
    }
    return 0;
}

